home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 36
/
Amiga Format CD36 (1999-01-22)(Future Publishing)(GB)[!][issue 1999-02].iso
/
-websites-
/
amosfactory
/
downloads
/
gui170.lha
/
AmosIRC.Amos
/
AmosIRC.amosSourceCode
next >
Wrap
AMOS Source Code
|
1998-03-29
|
6KB
|
238 lines
'**
'** $VER: AMOSPro IRC Client (17-10-97)
'** Release 1.0
'**
'** A (very...) simple IRC client
'**
'** � Copyright 1997 Pietro Ghizzoni - Dairymen Soft
'** FreeWare
'**
Set Buffer 30
Amos To Back : Dim MSG$(200),USER$(50)
Global MSG$(),HOST$,USER$,L$,P$,C$,COM,MSG,MSGA,SRV$,NAME$,PW$,NICK$,SPK,USER$()
Global TP$,USER,PAR$
'Obtain the HOST and USER names
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HOST$= Extension_24_0954("ENV:HOSTNAME") : USER$= Extension_24_0954("ENV:USERNAME")
L$=Chr$(13)+Chr$(10) : MSGA=Array(MSG$(0)) : Extension_24_0018 1,1,20
'Server and User settings
'~~~~~~~~~~~~~~~~~~~~~~~~~~
If Exist("ENV:AmosIRC.prefs")
Open In 2,"ENV:AmosIRC.prefs" : Input #2,NAME$,NICK$,SRV$,PW$ : Close 2
Else
PREFS
End If
'Open the connection and LOG file
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DISPLAY["AmosIRC | Connecting to "+SRV$]
IRC= Extension_24_0C9C(1,SRV$+"/6667") : Open Out 1,"bbs:AmosIRC.log"
If IRC
'** User Registration **
If Len(PW$) : A= Extension_24_0B04(1,"PASS "+PW$+L$) : End If
A= Extension_24_0B04(1,"NICK "+NICK$+L$)
A= Extension_24_0B04(1,"USER "+USER$+" "+HOST$+" "+SRV$+" :"+NAME$+L$)
Else
A= Extension_24_0150("AmosIRC","Unable to open the connection!","Uh?") : Goto _END
End If
'Enable the automatic data check
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CHK= Extension_24_0C06(1,0,0)
'This is the main loop.... simple eh? :)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do
CD= Extension_24_0034 : G$= Extension_24_0060
If CD=-9
If Extension_24_0B56 =CHK : Rem We have received a signal!
If Extension_24_0B46 =0
_VIEW : If COM=375 : A= Extension_24_0B04(1,"JOIN #AMOS"+L$) : End If
Else
A= Extension_24_0150("AmosIRC","Connection lost!","Uh?") : Exit
End If
End If
Else If CD=1
'Send your message to the IRC channel
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A= Extension_24_0C32(1,":"+NICK$+" PRIVMSG #AMOS :"+G$+L$,0) : DISPLAY[NICK$+" | "+G$]
Else If CD=-1
A= Extension_24_0B04(1,"QUIT :Amiga RULEZ!"+L$) : Exit : Rem Bye, Bye #AMOS....
Else If CD=4
TP$=G$ : A= Extension_24_0C32(1,":"+NICK$+" TOPIC #AMOS :"+G$+L$,0)
End If
Loop
_END: Close : Extension_24_0130 : Extension_24_0ADA
Procedure _VIEW
MSG : M$=Param$ : If M$="" Then Pop Proc
If P$=SRV$
S$="Server"
Else
C=Instr(P$,"!",1)-1 : If C=-1 : C=Instr(P$," ",1)-1 : End If
S$=Mid$(M$,2,C) : Rem Obtain the sender NICK
End If
L=Len(M$)-(Instr(M$,":",2)+1) : ME$=Right$(M$,L+1) : Rem Length of the message
If C$="PRIVMSG"
Extension_24_038C
Else If C$="JOIN"
ME$=S$+" has joined this channel" : USER[S$,1] : S$="Server"
Else If C$="PART"
ME$=S$+" has left this channel" : USER[S$,-1] : S$="Server"
Else If C$="TOPIC" or COM=332
TP$=ME$ : Extension_24_009E 1,4,0,Varptr(TP$)
If C$="TOPIC" : ME$=S$+" has changed the topic to "+ME$ : S$="Server" : End If
Else If COM=353
USER[ME$,0] : Pop Proc
Else If C$="MODE"
Pop Proc
End If
DISPLAY[S$+" | "+ME$]
End Proc
Procedure MSG
'Read the IRC commands line
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M$= Extension_24_0BE4(1) : COM=0 : Print #1,M$
If Asc(M$)=58
S=Instr(M$," ",2)+1 : P$=Mid$(M$,2,S-3) : Rem PREFIX
S1=Instr(M$," ",S) : C$=Mid$(M$,S,S1-S) : Rem COMMAND (ASCII)
COM=Val(C$) : Rem COMMAND (VALUE)
Else
'Handle the server PING/PONG authentication
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If Left$(M$,4)="PING" : A= Extension_24_0C32(1,"PONG "+SRV$+L$,0) : End If : M$=""
End If
If C$="PRIVMSG" : S=Instr(M$," ",S1+1) : PAR$=Mid$(M$,S1+1,S-S1-1) : End If
End Proc[M$]
Procedure DISPLAY[A$]
If MSG=201 : Extension_24_09F0 MSGA,0 : MSG=200 : End If
MSG$(MSG)=A$ : Inc MSG : Extension_24_009E 1,0,1,MSGA : Extension_24_009E 1,0,2,MSG
End Proc
Procedure PREFS
Dim EFN$(11) : Restore SERVERS : For I=0 To 11 : Read EFN$(I) : Next
Extension_24_0006 2,2 : Extension_24_03B6 2 : Extension_24_009E 2,6,1,Array(EFN$(0))
Repeat
GAD= Extension_24_0034 : CD= Extension_24_0052 : C$= Extension_24_0060
If GAD=4
SRV$= Extension_24_037A(2,1) : NAME$= Extension_24_037A(2,0) : NICK$= Extension_24_037A(2,2)
PW$= Extension_24_037A(2,3) : PRF$=NAME$+L$+NICK$+L$+SRV$+L$+PW$+L$
Extension_24_0944 "ENV:AmosIRC.prefs",PRF$ : Extension_24_0944 "ENVARC:AmosIRC.prefs",PRF$
Exit
Else If GAD=5
Exit
Else If GAD=6
A=Instr(C$,"-",1)+1 : A$=Right$(C$,Len(C$)-A) : Extension_24_009E 2,1,0,Varptr(A$)
End If
Until GAD=-1
Extension_24_03C6 : A= Extension_24_0042(2)
SERVERS:
Data "Germany - irc.uni-paderborn.de"
Data "USA - irc.stealth.net"
Data "USA - irc.colorado.edu"
Data "Finland - irc.funet.fi"
Data "Italy - irc.ccii.unipi.it"
Data "Italy - irc.flashnet.it"
Data "Israel - irc.tau.ac.il"
Data "Japan - irc.tokyo.wide.ad.jp"
Data "Australia - yoyo.cc.monash.edu.au"
Data "Belgium - othello.ulb.ac.be"
Data "Denmark - alk.iesd.auc.dk"
Data "France - sil.polytechnique.fr"
End Proc
Procedure USER[A$,M]
If M=0
Do
A=Instr(A$,"@",B) : B=Instr(A$," ",A)
If A>0 : USER$(USER)=Mid$(A$,A+1,B-A-1) : Inc USER Else Exit : End If
Loop
Else If M=1
USER$(USER)=A$ : Inc USER
Else If M=-1
For I=0 To USER : If USER$(I)=A$ : USER$(I)="" : End If : Next
End If
Extension_24_009E 1,2,1,Array(USER$(0))
End Proc